package com.tsmti.activiti.entity;

import com.tsmti.core.common.entity.ActBaseDataEntity;
import com.tsmti.core.common.entity.BaseDataEntity;
import org.hibernate.annotations.*;
import org.hibernate.validator.constraints.NotBlank;

import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.List;
import java.util.Map;

/**
 * @Package：com.tsmti.activiti.entity
 * @Class：ExtendActBusiness
 * @Description： TODO
 * @Author：zcw
 * @Date：Created in 2018/7/30 12:23
 * @Company:
 * @Version：
 * @Modified By:
 */
@Entity
@Table(name = "extend_act_business")
@DynamicInsert
@DynamicUpdate
@Where(clause = "delFlag = 0")
public class ExtendActBusiness extends ActBaseDataEntity<String> {
    private static final long serialVersionUID = -9070852531075418796L;
    /*** 表单可写*/
    private Map<String, String> writes;
    /*** 可设置为条件*/
    private Map<String, String> judgs;
    /*** 表单用户字段*/
    private Map<String, String> userFields;
    private String id;
    /**业务流程名字*/
    @NotBlank(message = "名称不能为空")
    private String name;
    /**流程key*/
    @NotBlank(message = "流程key不能为空")
    private String actKey;
    /**类路径*/
    private String classUrl;
    /**1=根节点 2=分组 3=业务类 4=回调*/
    private String type;
    /**父节点id*/
    @NotBlank(message = "父节点不能为空")
    private String parentId;
    /**同一级节点中的序号*/
    @NotBlank(message = "序号不能为空")
    private String sort;
    /**是否展开*/
    private String open;
    /**父节点名称*/
    private String parentName;

    /**备注*/
    private String remark;

    @Transient
    public Map<String, String> getWrites() {
        return writes;
    }

    public void setWrites(Map<String, String> writes) {
        this.writes = writes;
    }

    @Transient
    public Map<String, String> getJudgs() {
        return judgs;
    }

    public void setJudgs(Map<String, String> judgs) {
        this.judgs = judgs;
    }

    @Id
    @Override
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    public String getId() {
        return id;
    }

    @Override
    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getActKey() {
        return actKey;
    }

    public void setActKey(String actKey) {
        this.actKey = actKey;
    }

    public String getClassUrl() {
        return classUrl;
    }

    public void setClassUrl(String classUrl) {
        this.classUrl = classUrl;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public String getOpen() {
        return open;
    }

    public void setOpen(String open) {
        this.open = open;
    }

    @Formula(value = "(select f_t.name from extend_act_business f_t where f_t.id = parentId)")
    public String getParentName() {
        return parentName;
    }

    public void setParentName(String parentName) {
        this.parentName = parentName;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Transient
    public Map<String, String> getUserFields() {
        return userFields;
    }

    public void setUserFields(Map<String, String> userFields) {
        this.userFields = userFields;
    }
}
